package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.CldStaffContractStatics;
import com.cleaningcloud.cld.domain.dto.CldStaffContractDto;
import com.cleaningcloud.cld.domain.vo.CldStaffContractVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldStaffContract;
import com.cleaningcloud.cld.service.ICldStaffContractService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 人事合同Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-22
 */
@RestController
@RequestMapping("/staffContract")
public class CldStaffContractController extends BaseController
{
    @Autowired
    private ICldStaffContractService cldStaffContractService;

    /**
     * 查询人事合同列表
     */
    @RequiresPermissions("cld:staffContract:list")
    @GetMapping("/list")
    public TableDataInfo list(CldStaffContractDto cldStaffContract)
    {
        startPage();
        List<CldStaffContractVo> list = cldStaffContractService.selectCldStaffContractList(cldStaffContract);
        return getDataTable(list);
    }

    /**
     * 查询人事合同汇总列表
     */
    @RequiresPermissions("cld:staffContract:list")
    @GetMapping("/staffContractStatistics")
    public TableDataInfo staffContractStatistics(CldStaffContractStatics cldStaffContractStatics)
    {
        startPage();
        List<CldStaffContractStatics> list = cldStaffContractService.staffContractStatistics(cldStaffContractStatics);
        return getDataTable(list);
    }


    /**
     * 获取人事合同详细信息
     */
    @RequiresPermissions("cld:staffContract:query")
    @GetMapping(value = "/{staffContractId}")
    public AjaxResult getInfo(@PathVariable("staffContractId") Long staffContractId)
    {
        return success(cldStaffContractService.selectCldStaffContractByStaffContractId(staffContractId));
    }

    /**
     * 新增人事合同
     */
    @RequiresPermissions("cld:staffContract:add")
    @Log(title = "人事合同", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldStaffContract cldStaffContract)
    {
        cldStaffContract.setEditPost(true);
        return toAjax(cldStaffContractService.insertCldStaffContract(cldStaffContract));
    }

    /**
     * 修改人事合同
     */
    @RequiresPermissions("cld:staffContract:edit")
    @Log(title = "人事合同", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldStaffContract cldStaffContract)
    {
        return toAjax(cldStaffContractService.updateCldStaffContract(cldStaffContract));
    }

    /**
     * 删除人事合同
     */
    @RequiresPermissions("cld:staffContract:remove")
    @Log(title = "人事合同", businessType = BusinessType.DELETE)
	@DeleteMapping("/{staffContractIds}")
    public AjaxResult remove(@PathVariable Long[] staffContractIds)
    {
        return toAjax(cldStaffContractService.deleteCldStaffContractByStaffContractIds(staffContractIds));
    }
}
